<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>上下居中</title>
<style>
.container{
  width: 500px;
  height: 400px;
  border: 2px solid #379;
  position: relative;
}
.inner{
  width: 280px;
  height: 180px;
  background-color: #746;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -90px; /*height的一半*/
  margin-left: -140px; /*width的一半*/
 }

</style>
</head>
<body>
	<div class="container">
		<div class="inner"></div>
	</div>
</body>
</html>